package com.it.commicity.service.impl.zy;

import com.it.commicity.common.Result;
import com.it.commicity.domain.po.ZyBuilding;
import com.it.commicity.domain.po.ZyCommunity;
import com.it.commicity.mapper.zy.ZyBuildingMapper;
import com.it.commicity.service.zy.IZyBuildingService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 楼栋  服务实现类
 * </p>
 *
 * @author author
 * @since 2025-07-11
 */
@Service
public class ZyBuildingServiceImpl extends ServiceImpl<ZyBuildingMapper, ZyBuilding> implements IZyBuildingService {
    @Autowired
    private ZyBuildingMapper buildingMapper;

    @Override
    public Result<List<ZyCommunity>> getAllCommunity() {
        List<ZyCommunity> listResult = buildingMapper.getAllCommunity();
        if (listResult.isEmpty()) {
            return Result.fail("查询失败");
        }
        return Result.success(listResult);
    }

    @Override
    public Result<List<ZyBuilding>> getAllBuilding() {
        return Result.success(buildingMapper.selectList(null));
    }
}
